package com.example.demo;

import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Component;
import tbs.framework.async.container.IAsyncTaskService;
import tbs.framework.async.notifiers.ICancelNotifier;
import tbs.framework.async.task.IAsyncTask;
import tbs.framework.async.task.ICancelable;
import tbs.framework.log.ILogger;
import tbs.framework.log.annotations.AutoLogger;

@Component
public class LogCancelNotifier implements ICancelNotifier {

    @AutoLogger
    ILogger logger;

    @Override
    public void cancelTaskNotify(@NotNull ICancelable cancelable, @NotNull IAsyncTask asyncTask,
        @NotNull IAsyncTaskService container) {
        logger.info("Task {} was canceled,reason:{}", asyncTask.taskId(), cancelable.cancelReason());
    }
}
